package com.hpf.lease.web.admin.controller;

import com.hpf.lease.common.result.Result;
import com.hpf.lease.model.bean.LabelInfo;
import com.hpf.lease.web.admin.service.LabelInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/label")
@Tag(name = "标签管理模块")
public class LabelInfoController {
    @Resource
    LabelInfoService labelInfoService;
    @PostMapping("/saveOrUpdate")
    @Operation(summary = "根据id更新或修改label标签")
    public Result<Object> saveOrUpdate(@RequestBody LabelInfo labelInfo){
        return Result.build(labelInfoService.saveOrUpdateInfo(labelInfo));
    }
    @GetMapping("/list")
    @Operation(summary = "查询所有")
    public Result<List<LabelInfo>> selectAll(@RequestParam(required = false) Long type){
        return Result.ok(labelInfoService.selectAll(type));
    }
    @DeleteMapping("/deleteById")
    @Operation(summary = "根据id删除label标签")
    public Result<Object> deleteById(@RequestParam Long id){
        return Result.build(labelInfoService.removeById(id));
    }
}
